<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<title>title</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/common.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/complaint_details.css"/>
		<style>
			body {
			}
			.m-t {
				margin-top: 10px;
			}
			.m-l {
				margin-left: 30px;
			}
			.m-l-2 {
				margin-left: 13px;
			}
			.color-1 {
				color: #6e6e6e;
			}
			.color-2 {
				color: #b4b4b4;
			}
			.color-3 {
				color: #ff0f2e;
			}
			.color-4 {
				color: #ff8000;
			}
			.color-5 {
				color: #999999;
			}
			/* 接障详情处理结果 */
			.order-result-container {
				margin-top: 20px;
				padding: 15px 15px 0;
				border-top: #c2c2c2 1px solid;
			}
			.btn-container {
				padding: 28px 7.5px 38px;
			}
			.btn-s {
				padding: 10px 0;
				text-align: center;
				background-color: #f2a23a;
				color: #fff;
				border-radius: 4px;
			}
			/* 描述输入框 */
			.input-compldescribe-container {
				padding: 10px;
				border: #aaaaaa 1px solid;
				border-radius: 5px;
			}
			.input-compldescribe {
				height: 230px;
				width: 100%;
				outline: none;
				font-size: 14px;
			}
			.input-compldescribe-words-n {
				text-align: right;
			}
			.input-compldescribe-words-n:after {
				content: "/300字";
			}
			/* 故障情况输入框 */
			.input-container {
				margin-top: 13px;
			}
			.input-container > div:nth-child(2) {
				height: 30px;
				line-height: 30px;
				border: #C2C2C2 1px solid;
				border-radius: 5px;
				padding: 0 15px;
			}
		</style>
	</head>
	<body>
		<div class="commit-content-container">
			<div class="commit-content-title flex-container flex-between">
				<div id="acms-msg-1">
					--
				</div>
				<div id="acms-msg-2" class="color-4">
					--
				</div>
			</div>
			<div class="commit-content-msg">
				<div>
					<span class="commit-content-msg-title">联系电话：</span><span id="acms-msg-3" class="phone_style">-</span>
				</div>
				<div id="div-acms-msg-16">
					<span class="commit-content-msg-title">校园卡号：</span><span id="acms-msg-16">-</span>
				</div>
				<div>
					<span class="commit-content-msg-title">故障地点：</span><span id="acms-msg-4">--</span>
				</div>
				<div>
					<span class="commit-content-msg-title">具体地址：</span><span id="acms-msg-5">--</span>
				</div>
				<div>
					<span class="commit-content-msg-title">网络类型：</span><span id="acms-msg-6">--</span>
				</div>
				<div>
					<span class="commit-content-msg-title">报障时间：</span><span id="acms-msg-7">--</span>
				</div>
				<div>
					<span class="commit-content-msg-title">故障情况：</span><span id="acms-msg-8">--</span>
				</div>
				<div>
					<span class="commit-content-msg-title">故障描述：</span>
					<div id="acms-msg-9">
						--
					</div>
				</div>
			</div>
			<div id="acms-msg-10-p" class="camera-container mg-t">
				<img  id="acms-msg-10" class="camera-container-img" src="" />
				<div class="camera-container-delete"></div>
			</div>
		</div>
		<div class="acms-c-1" style="display: block";>
			<div class="order-result-container">
				<!-- 已受理 -->
				<div>
					<span>处理员：</span><span id="acms-c-1-msg-1" class="color-4">--</span>
				</div>
				<div class="m-t color-5">
					<span>接障时间：</span><span id="acms-c-1-msg-2">--</span>
				</div>
				<div class="btn-container">
					<div class="btn-s" id="acms-c-1-msg-3">
						开始处理
					</div>
				</div>
			</div>
		</div>
		<!-- 处理中 -->
		<div class="acms-c-2" style="display: block";>
			<div class="order-result-container">
				<div>
					<span>处理员：</span><span id="acms-c-2-msg-1" class="color-4">--</span>
				</div>
				<div></div>
				<div class="m-t color-5">
					<span>接障时间：</span><span id="acms-c-2-msg-2">--</span>
				</div>
				<div class="m-t flex-container flex-center-v">
					<div class="color-5">
						<nobr>
							处理状态：
						</nobr>
					</div>
					<div class="flex-container">
						<div class="flex-container flex-center-v" id="acms-c-2-msg-3-p">
							<div class="icon-normal icon-checked-normal" id="acms-c-2-msg-3"></div>
							<div class="m-l-2">
								<nobr>
									已解决
								</nobr>
							</div>
						</div>
						<div class="flex-container flex-center-v m-l" id="acms-c-2-msg-4-p">
							<div class="icon-normal icon-checked-normal" id="acms-c-2-msg-4"></div>
							<div class="m-l-2">
								<nobr>
									未解决
								</nobr>
							</div>
						</div>
					</div>
				</div>
				<!--<div class="color-5 input-container flex-container flex-center-v">
				<div class="f-1">
				<nobr>
				故障情况：
				</nobr>
				</div>
				<div class="flex-item">
				<div id="showCpHandle" class="f-2 icon-arrow-bottom">
				--
				</div>
				</div>
				</div>-->
				<div class="">
					<div class="color-5 m-t">
						处理描述：
					</div>
					<div class="m-t input-compldescribe-container">
						<textarea class="input-compldescribe" placeHolder="请输入处理描述" maxlength="300" id="acms-c-2-msg-5"></textarea>
						<div class="input-compldescribe-words-n" id="acms-c-2-msg-6">
							0
						</div>
					</div>
				</div>
				<div class="camera-container mg-t">
					<img class="camera-container-img" src=""  id="acms-c-2-msg-7"/>
					<div class="camera-container-delete" id="acms-c-2-msg-8"></div>
				</div>
				<div class="none btn-container">
					<div class="btn-s" id="acms-c-2-msg-9">
						提交
					</div>
				</div>
			</div>
		</div>
		<!-- 不可修改的处理结果 -->
		<div id="acms-c-4" style="display: block">
			<div class="order-result-container">
				<div>
					<span>处理员：</span><span id="acms-c-4-msg-1" class="color-4">--</span>
				</div>
				<div class="m-t color-5">
					<span>接障时间：</span><span id="acms-c-4-msg-2">--</span>
				</div>
				<div class="m-t color-5">
					<span>处理时间：</span><span id="acms-c-4-msg-3">--</span>
				</div>
				<div class="m-t color-5">
					<span>处理状态：</span><span id="acms-c-4-msg-4">--</span>
				</div>
				<div>
					<div class="m-t color-5">
						处理情况：
					</div>
					<div class="m-t" id="acms-c-4-msg-5">
						--
					</div>
				</div>
				<div id="acms-c-4-msg-6-p" class="camera-container mg-t">
					<img class="camera-container-img" src=""  id="acms-c-4-msg-6"/>
					<div class="camera-container-delete"></div>
				</div>
			</div>
		</div>
		<!-- 可修改的处理结果 -->
		<div class="acms-c-3" style="display: block";>
			<div class="order-result-container">
				<div>
					<span>处理员：</span><span id="acms-c-3-msg-1" class="color-4">--</span>
				</div>
				<div></div>
				<div class="m-t color-5">
					<span>接障时间：</span><span id="acms-c-3-msg-2">--</span>
				</div>
				<div class="m-t flex-container flex-center-v">
					<div class="color-5">
						<nobr>
							处理状态：
						</nobr>
					</div>
					<div class="flex-container">
						<div id="acms-c-3-msg-3-p" class="flex-container flex-center-v">
							<div class="icon-normal icon-checked-normal" id="acms-c-3-msg-3"></div>
							<div class="m-l-2">
								<nobr>
									已解决
								</nobr>
							</div>
						</div>
						<div id="acms-c-3-msg-4-p" class="flex-container flex-center-v m-l">
							<div class="icon-normal icon-checked-normal" id="acms-c-3-msg-4"></div>
							<div class="m-l-2">
								<nobr>
									未解决
								</nobr>
							</div>
						</div>
					</div>
				</div>
				<!--<div class="color-5 input-container flex-container flex-center-v">
				<div class="f-1">
				<nobr>
				故障情况：
				</nobr>
				</div>
				<div class="flex-item">
				<div id="acms-c-3-msg-9" class="f-2 icon-arrow-bottom">
				--
				</div>
				</div>
				</div>-->
				<div class="">
					<div class="color-5 m-t">
						处理描述：
					</div>
					<div class="m-t input-compldescribe-container">
						<textarea class="input-compldescribe" placeHolder="请输入处理描述" maxlength="300" id="acms-c-3-msg-5"></textarea>
					</div>
				</div>
				<div id="acms-c-3-msg-6-p" class="camera-container mg-t">
					<img class="camera-container-img" src=""  id="acms-c-3-msg-6"/>
					<div class="camera-container-delete" id="acms-c-3-msg-7"></div>
				</div>
				<div class="none btn-container">
					<div class="btn-s" id="acms-c-3-msg-8">
						提交
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/request.js"></script>
	<script type="text/javascript">
		//调用pop的标记。图片==1，故障处理情况==2；
		var mPopTag = 1;
		//回调函数(图片的弹窗)
		var mPicCallback;
		//回调函数(故障处理情况的弹窗)
		var mCpCallback;
		//故障处理情况的数据
		var mCpHandleDatas;
		var mPic64;
		var mStatus;
		var mC1;
		var mC2;
		var mC3;
		var mC4;
		//是否请求开始报障成功
		var isStartHandle = false;
		//故障id
		var mCpId;
		//故障处理上传图片的img
		var mGetpic;
		//删除图片
		var mDletepic;
		apiready = function() {
			initData();
			requestCpDetails(mCpId);
			setPopItemClickListener();
		};
		function initData() {
			mCpId = api.pageParam.id;
		}

		/**
		 * 初始化view
		 * @param{JSON} data - 服务器请求获取到的报障详情数据
		 */
		function initView(data) {
			var status = data.status;
			mStatus = status;
			//是否二次受理过
			var isTwo = data.two == 0 ? false : true;
			var doc = document;
			refreshView(doc);
			showView(doc, data);
			//故障状态
			var msg2 = doc.getElementById('acms-msg-2');
			//状态： 1 待处理 2.已受理 3 .处理中  4.已处理 5.疑难单 6.报障关闭 7.已完成
			if (status == 2) {
				showView1(doc, data);
				if (isTwo) {
					msg2.innerText = '二次受理';
				} else {
					msg2.innerText = '已受理';
				}
			} else if (status == 3) {
				showView2(doc, data);
				if (isTwo) {
					msg2.innerText = '二次处理中';
				} else {
					msg2.innerText = '处理中';
				}
			} else if (status == 4) {
				msg2.innerText = '已处理';
				if (isTwo) {
					msg2.innerText = '已二次处理';
					showView4(doc, data);
					showView3(doc, data, isTwo);
				} else {
					msg2.innerText = '已处理';
					showView3(doc, data, isTwo);
				}
			} else {
				MyCom.errorTip(2);
			}
		}

		function refreshView(doc) {
			mC1 = doc.getElementsByClassName('acms-c-1')[0];
			mC2 = doc.getElementsByClassName('acms-c-2')[0];
			mC3 = doc.getElementsByClassName('acms-c-3')[0];
			mC4 = doc.getElementById('acms-c-4');
			mC1.style.display = 'none';
			mC2.style.display = 'none';
			mC3.style.display = 'none';
			mC4.style.display = 'none';
		}

		function showView(doc, data) {
			//报障人
			var msg1 = doc.getElementById('acms-msg-1');
			msg1.innerText = MyCom.dataFaultTolerant(data.nick_name);
			//电话
			var msg3 = doc.getElementById('acms-msg-3');
			msg3.innerText = MyCom.dataFaultTolerant(data.user_phone);

			//校园卡号
			var msg16 = doc.getElementById('acms-msg-16');
				console.log(".......msg16............"+data.school_number);
				if(typeof(data.school_number) == 'undefined' || typeof(data.school_number) === ''){
					var divMsg16 = doc.getElementById('div-acms-msg-16');
					divMsg16.style.display = 'none';
				}else {
						msg16.innerText = MyCom.dataFaultTolerant(data.school_number);
				}

			//故障地点
			var msg4 = doc.getElementById('acms-msg-4');
			msg4.innerText = MyCom.dataFaultTolerant(data.warn_location);
			//具体地址
			var msg5 = doc.getElementById('acms-msg-5');
			msg5.innerText = MyCom.dataFaultTolerant(data.address);
			//网络类型
			var msg6 = doc.getElementById('acms-msg-6');
			if (data.internet_type == 1) {
				msg6.innerText = '宽带网络';
			} else {
				msg6.innerText = 'WiFi';
			}
			//报障时间
			var msg7 = doc.getElementById('acms-msg-7');
			msg7.innerText = MyCom.dataFaultTolerant(data.create_time);
			//故障情况
			var msg8 = doc.getElementById('acms-msg-8');
			msg8.innerText = MyCom.dataFaultTolerant(data.title);
			//故障描述
			var msg9 = doc.getElementById('acms-msg-9');
			msg9.innerText = MyCom.dataFaultTolerant(data.content);
			//报障上传的图片
			var msg10P = doc.getElementById('acms-msg-10-p');
			var msg10 = doc.getElementById('acms-msg-10');
			if (data.images == null) {
				msg10P.style.display = 'none';
			} else {
				msg10P.style.display = 'block';
				msg10.src = MyCom.dataFaultTolerant(data.images);
				msg10P.onclick = function() {
					openLargePicPg(data.images);
				}
			}
			msg3.onclick = function() {
				MyCom.callPhone(data.user_phone);
			}
		}

		/**
		 * 展示“已受理”模块
		 */
		function showView1(doc, data) {
			console.log('showView1');
			mC1.style.display = 'block';
			//接障时间
			var msg_1 = doc.getElementById('acms-c-1-msg-1');
			//处理员
			var msg_2 = doc.getElementById('acms-c-1-msg-2');
			//开始处理按钮
			var msg_3 = doc.getElementById('acms-c-1-msg-3');
			msg_1.innerText = MyCom.dataFaultTolerant(data.action_person) + MyCom.dataFaultTolerant(data.action_phone);
			msg_2.innerText = MyCom.dataFaultTolerant(data.dispatch_time);
			msg_3.onclick = function() {
				if (!isStartHandle) {
					requestStartDeal(mCpId);
				} else {
					api.toast({
						msg : '已经提交了开始处理的申请'
					});
				}
			}
		}

		/**
		 * 展示“处理中”模块
		 */
		function showView2(doc, data) {
			console.log('showView2');
			mC2.style.display = 'block';
			//处理员
			var msg_1 = doc.getElementById('acms-c-2-msg-1');
			//接障时间
			var msg_2 = doc.getElementById('acms-c-2-msg-2');
			//处理状态：已解决
			var msg_3_p = doc.getElementById('acms-c-2-msg-3-p');
			var msg_3 = doc.getElementById('acms-c-2-msg-3');
			//处理状态：未解决
			var msg_4_p = doc.getElementById('acms-c-2-msg-4-p');
			var msg_4 = doc.getElementById('acms-c-2-msg-4');
			//处理描述
			var msg_5 = doc.getElementById('acms-c-2-msg-5');
			//字数
			var msg_6 = doc.getElementById('acms-c-2-msg-6');
			//处理上传图片
			var msg_7 = doc.getElementById('acms-c-2-msg-7');
			//移除处理上传图片按钮
			var msg_8 = doc.getElementById('acms-c-2-msg-8');
			//提交
			var msg_9 = doc.getElementById('acms-c-2-msg-9');
			//故障处理情况
			//			var msg_10 = doc.getElementById('acms-c-2-msg-10');
			msg_1.innerText = MyCom.dataFaultTolerant(data.action_person) + MyCom.dataFaultTolerant(data.action_phone);
			msg_2.innerText = MyCom.dataFaultTolerant(data.dispatch_time);
			msg_7.onclick = function() {
				var datas = [{
					title : '拍照'
				}, {
					title : '从手机选择'
				}];
				var index;
				var url;
				//弹出选择框
				showPicSelect(datas, 'bottom');
				mPicCallback = function(index) {
					console.log('index--' + index);
					if (index == 0) {
						url = getPic('camera', function(url) {
							msg_7.src = url;
							msg_8.style.display = 'block'
						});
					} else {
						getPic('album', function(url) {
							msg_7.src = url;
							msg_8.style.display = 'block'
						});
					}
				}
			}
			msg_8.onclick = function() {
				//删除图片
				msg_7.src = '../../image/icon_touming.png';
				msg_8.style.display = 'none'
			}
			//显示输入字数
			msg_5.onkeyup = function() {
				msg_6.innerText = msg_5.value.length;
			}
			//提交
			msg_9.onclick = function() {
				var s;
				if (msg_4.className.indexOf('active') != -1) {//未解决
					s = 2;
				} else if (msg_3.className.indexOf('active') != -1) {//已解决
					s = 1;
				} else {
					s = null;
				}
				requestCommitDealResult(s, msg_5.value);
			}
			//			msg_10.onclick = function() {
			//				mCpCallback = function(index) {
			//					msg_10.innerText = mCpHandleDatas[index];
			//				}
			//				showCpHandle(datas, 'bottom');
			//			}
			setNetTypeChange(msg_3_p, msg_4_p, msg_3, msg_4);
		}

		/**
		 * 展示可编辑的“已处理”模块
		 */
		function showView3(doc, data, isTwo) {
			console.log('showView3');
			mC3.style.display = 'block';
			//服务器数据：处理员
			var s_1;
			//服务器数据：接障时间
			var s_2;
			//服务器数据：处理状态
			var s_3;
			//服务器数据：处理描述
			var s_4;
			//服务器数据：处理图片
			var s_5;
			if (isTwo) {
				s_1 = MyCom.dataFaultTolerant(data.two_action_person) + MyCom.dataFaultTolerant(data.two_action_phone);
				s_2 = MyCom.dataFaultTolerant(data.two_dispatch_time);
				s_3 = data.two_action_status == 1 ? true : false;
				s_4 = MyCom.dataFaultTolerant(data.two_action_result);
				s_5 = data.two_action_imges;
			} else {
				s_1 = MyCom.dataFaultTolerant(data.action_person) + MyCom.dataFaultTolerant(data.action_phone);
				s_2 = MyCom.dataFaultTolerant(data.dispatch_time);
				s_3 = data.action_status == 1 ? true : false;
				s_4 = MyCom.dataFaultTolerant(data.action_result);
				s_5 = data.images;
			}
			//处理员
			var msg_1 = doc.getElementById('acms-c-3-msg-1');
			//接障时间
			var msg_2 = doc.getElementById('acms-c-3-msg-2');
			//处理状态:已解决
			var msg_3 = doc.getElementById('acms-c-3-msg-3');
			var msg_3_p = doc.getElementById('acms-c-3-msg-3-p');
			//处理状态:未解决
			var msg_4 = doc.getElementById('acms-c-3-msg-4');
			var msg_4_p = doc.getElementById('acms-c-3-msg-4-p');
			//处理描述
			var msg_5 = doc.getElementById('acms-c-3-msg-5');
			//处理上传的图片
			var msg_6 = doc.getElementById('acms-c-3-msg-6');
			var msg_6_p = doc.getElementById('acms-c-3-msg-6-p');
			var msg_7 = doc.getElementById('acms-c-3-msg-7');
			var msg_8 = doc.getElementById('acms-c-3-msg-8');
			//故障处理情况
			//			var msg_9 = doc.getElementById('acms-c-3-msg-9');
			msg_1.innerText = s_1;
			msg_2.innerText = s_2;
			if (s_3) {//已解决
				msg_3.className = 'icon-normal icon-checked active';
				msg_4.className = 'icon-normal icon-checked-normal';
			} else {//未解决
				msg_4.className = 'icon-normal icon-checked active';
				msg_3.className = 'icon-normal icon-checked-normal';
			}
			setNetTypeChange(msg_3_p, msg_4_p, msg_3, msg_4);
			msg_5.innerText = s_4;
			if (s_5 == null) {
				msg_6_p.style.display = 'none';
				msg_6.src = '';
			} else {
				msg_6_p.style.display = 'block';
				msg_6.src = s_5;
			}
			msg_6.onclick = function() {
				var datas = [{
					title : '拍照'
				}, {
					title : '从手机选择'
				}];
				var index;
				var url;
				//弹出选择框
				showPicSelect(datas, 'bottom');
				mPicCallback = function(index) {
					console.log('index--' + index);
					if (index == 0) {
						url = getPic('camera', function(url) {
							msg_6.src = url;
							msg_7.style.display = 'block';
						});
					} else {
						getPic('album', function(url) {
							msg_6.src = url;
							msg_7.style.display = 'block';
						});
					}
				}
			}
			//提交
			msg_8.onclick = function() {
				var s;
				if (msg_4.className.indexOf('active') != -1) {//未解决
					s = 2;
				} else if (msg_3.className.indexOf('active') != -1) {//已解决
					s = 1;
				} else {
					s = null;
				}
				requestCommitDealResult(s, msg_5.value);
			}
			//			msg_9.onclick = function() {
			//				mCpCallback = function(index) {
			//					msg_10.innerText = mCpHandleDatas[index];
			//				}
			//				showCpHandle(datas, 'bottom');
			//			}
		}

		/**
		 * 展示不可编辑的“已处理”模块
		 */
		function showView4(doc, data) {
			console.log('showView4');
			mC4.style.display = 'block';
			//处理结果:已解决&未解决
			var handleR = data.action_status == 1 ? true : false;
			//故障处理图片
			var handleP = data.action_imges;
			//处理员
			var msg_1 = doc.getElementById('acms-c-4-msg-1');
			//接障时间
			var msg_2 = doc.getElementById('acms-c-4-msg-2');
			//处理时间
			var msg_3 = doc.getElementById('acms-c-4-msg-3');
			//处理状态
			var msg_4 = doc.getElementById('acms-c-4-msg-4');
			//处理描述
			var msg_5 = doc.getElementById('acms-c-4-msg-5');
			//处理上传的图片
			var msg_6 = doc.getElementById('acms-c-4-msg-6');
			var msg_6_p = doc.getElementById('acms-c-4-msg-6-p');
			msg_1.innerText = MyCom.dataFaultTolerant(data.action_person) + MyCom.dataFaultTolerant(data.action_phone);
			msg_2.innerText = MyCom.dataFaultTolerant(data.dispatch_time);
			msg_3.innerText = MyCom.dataFaultTolerant(data.action_time);
			if (handleR == 1) {//已解决
				msg_4.innerText = '已解决';
			} else {//未解决
				msg_4.innerText = '未解决';
			}
			msg_5.innerText = MyCom.dataFaultTolerant(data.action_result);
			if (handleP == null) {
				msg_6_p.style.display = 'none';
			} else {
				msg_6_p.style.display = 'block';
				msg_6.src = handleP;
				msg_6_p.onclick = function() {
					openLargePicPg(handleP);
				}
			}
		}

		/**
		 * 已解决&未解决切换
		 * @param{HtmlDom} view1 - 可被点击的view（已解决按钮）
		 * @param{HtmlDom} view2 - 可被点击的view(未解决按钮)
		 */
		function setNetTypeChange(view1, view2, childView1, childView2) {
			view1.onclick = function() {
				if (childView1.className.indexOf('active') == -1) {
					childView2.className = 'icon-normal icon-checked-normal';
					childView1.className = 'icon-normal icon-checked active';
				}
			}
			view2.onclick = function() {
				if (childView2.className.indexOf('active') == -1) {
					childView1.className = 'icon-normal icon-checked-normal';
					childView2.className = 'icon-normal icon-checked active';
				}
			}
		}

		/**
		 * 展示故障处理情况的p弹窗
		 */
		function showCpHandle(datas, type) {
			MyCom.pop(datas, type, '../popView.html');
		}

		/**
		 * 展示图片选择按钮的弹窗
		 */
		function showPicSelect(datas, type) {
			MyCom.pop(datas, type, '../popView.html');
		}

		/**
		 * 从手机获取图片
		 * @param{String} type - 图片源类型，从相册album、图片库library或相机camera获取图片
		 */
		function getPic(type, callback) {
			api.getPicture({
				sourceType : type,
				encodingType : 'png',
				mediaValue : 'pic',
				destinationType : 'base64',
				allowEdit : false,
				quality : 100,
				targetWidth : 720,
				targetHeight : 1080,
				saveToPhotoAlbum : false
			}, function(ret, err) {
				if (ret) {
					mPic64 = ret.base64Data;
					if (mPic64 != '' && mPic64 != null) {
						callback(mPic64);
					}
				} else {
				}
			});
		}

		/**
		 * 打开大图页
		 * @param{String} url - 图片url
		 */
		function openLargePicPg(url) {
			api.openWin({
				name : 'ImageShow',
				url : '../ImageShow.html',
				pageParam : {
					'url' : url
				}
			});
		}

		/**
		 * 服务器请求：开始处理故障
		 *  @param{Number} cpid - 故障id
		 */
		function requestStartDeal(cpid) {
			api.showProgress({
			});
			var data = {
				values : {
					'id' : cpid
				}
			};
			var url = $api.getStorage(MyCom.key_server) + MyRequest.URL_START_HANDLE;
			MyRequest.requestMethod(url, data, function(re) {
				if (re) {
					var code = re.code;
					if (code == 1) {
						isStartHandle = true;
						requestCpDetails(cpid);
						api.hideProgress();
					} else {
					}
				} else {
					api.hideProgress();
					MyCom.errorTip(2);
				}
			});
		}

		/**
		 * 服务器请求：提交处理结果
		 */
		function requestCommitDealResult(s, r) {
			if (s == null) {
				api.toast({
					msg : '请选择处理状态！'
				});
				return;
			}
			if (r == null || r == '') {
				api.toast({
					msg : '处理描述不能为空！'
				});
				return;
			}
			api.showProgress({
			});
			var data = {
				values : {
					'id' : mCpId,
					'action_status' : s,
					'action_result' : r
				}
			};
			if (mPic64 != null) {
				data.values.imges = mPic64;
			}
			var url = $api.getStorage(MyCom.key_server) + MyRequest.URL_COMMIT_HANDLE_RESULT;
			MyRequest.requestMethod(url, data, function(re) {
				if (re) {
					console.log('提交处理结果--re=' + JSON.stringify(re));
					var code = re.code;
					api.hideProgress();
					if (code == 1) {
						api.toast({
							msg : '提交成功'
						});
						//如果在提交之前，状态不是已处理，那么就删除列表item
						if (mStatus == 4) {
						} else {
							triggerRemoveItemListener();
							api.closeWin({
							});
						}
					} else {
						api.toast({
							msg : re.msg
						});
					}
				} else {
					api.hideProgress();
					MyCom.errorTip(2);
				}
			});
		}

		/**
		 * 服务器请求：获取报障详情
		 * @param{Number} cpid - 故障id
		 */
		function requestCpDetails(cpid) {
			//如果不是提交或开始处理的请求，那么就弹出提示框。
			if (isStartHandle) {
			} else {
				api.showProgress({
				});
			}
			var data = {
				values : {
					'id' : cpid
				}
			};
			var url = $api.getStorage(MyCom.key_server) + MyRequest.URL_CP_DETAILS;
			MyRequest.requestMethod(url, data, function(re) {
				if (re) {
					console.log('获取故障详情--re=' + JSON.stringify(re));
					var code = re.code;
					var list = re.list[0];
					if (code == 1) {
						initView(list);
						api.hideProgress();
					} else {
						api.hideProgress();
						if (isStartHandle) {
							api.toast({
								msg : '已经开始处理，但数据刷新失败'
							});
						} else {
							api.toast({
								msg : re.msg
							});
						}
					}
				} else {
					api.hideProgress();
					if (isStartHandle) {
						api.toast({
							msg : '已经开始处理，但数据刷新失败'
						});
					} else {
						MyCom.errorTip(2);
					}
				}
			});
		}

		/**
		 * 触发“移除item”的监听
		 */
		function triggerRemoveItemListener() {
			api.sendEvent({
				name : 'RemoveItemListener'
			});
		}

		/**
		 * 设置pop item点击事件
		 * @param{Number} index - pop的item的下标
		 */
		function setPopItemClickListener() {
			var thisIndex;
			api.addEventListener({
				name : 'PopItemClickListener'
			}, function(ret, err) {
				if (ret) {
					thisIndex = ret.value.index;
					if (mPopTag == 1) {
						mPicCallback(thisIndex);
					} else if (mPopTag == 2) {
						mCpCallback(thisIndex);
					} else {
						MyCom.errorTip(1);
					}
				} else {
					MyCom.errorTip(1);
				}
			});
		}
	</script>
</html>
